package com.example.cloud.alibaba.seata.account.service;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.cloud.alibaba.seata.account.entity.TAccount;
import com.example.cloud.alibaba.seata.account.mapper.TAccountMapper;
import com.example.cloud.alibaba.seata.common.dto.AccountDTO;
import com.example.cloud.alibaba.seata.common.utils.SimpleMessage;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * * @author lidong
 * @since 2019-09-04
 */
@Service
public class TAccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> implements ITAccountService {

    @Override
    public SimpleMessage decreaseAccount(AccountDTO accountDTO) {
        int account = baseMapper.decreaseAccount(accountDTO.getUserId(), accountDTO.getAmount().doubleValue());
        if (account > 0){
            return SimpleMessage.info(account);
        }
        return SimpleMessage.fail("创建失败");
    }
}
